

#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

#include "common/utils.hpp"

int maxDepth(TreeNode* root) {
    int result = 0;
    std::queue<TreeNode*> queue;
    
    if (root != nullptr) queue.push(root);

    while(!queue.empty()) {
        int size = queue.size();
        for (int i = 0; i < size; i++) {
            TreeNode* node = queue.front();
            queue.pop();
            if (node->left) queue.push(node->left);
            if (node->right) queue.push(node->right);
        }

        if (size > 0) {
            result++;
        }
    }

    return result;
}

extern TreeNode* commonRoot;

int main() {
    int res = maxDepth(commonRoot);
    std::cout << "res: " << res << "\n";
}